<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.js"></script>
</head>
<body>
  <button>request请求</button>
  <button>post请求</button>
</body>
<script type="text/javascript">
  const btns = document.getElementsByTagName("button");

  //Get请求
  btns[0].onclick = function (){
    axios.request({
      method:"GET",
      url:"http://localhost:3000/comments",
    }).then(response =>{
      console.log(response);
    })
  }

  //post请求
  btns[1].onclick = function (){
    axios.post("http://localhost:3000/comments",{
      "body":"喜大普奔",
      "postId":2
    }).then(response =>{
      console.log(response);
    })
  }
</script>
</html>